home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / Libraries / VideoToolbox 96.06.15 / VideoToolboxSources / Nan.c < prev    next >
Text File  |  1995-08-13  |  1KB  |  45 lines

  1. /*
  2. Nan.c
  3. This file declares a global constant, Nan, that represents a const double 
  4. with the value nan("21"). Here's a typical use:
  5.     x=Nan;
  6. "Nan" is defined in VideoToolbox.h as *(double *)__NAN. The virtue of this
  7. approach, rather than just computing a NAN, e.g. 0.0/0.0, is that it's faster.
  8. Secondly, there's bug in the THINK C Debugger (versions 6.01 through 7.03) on
  9. the PowerBook 170 that causes it to stop with a fatal error message when trying
  10. to compute 0.0/0.0 while Virtual Memory is enabled. 
  11.  
  12. This scheme should also work fine as native code on the PowerPC.
  13.  
  14. HISTORY:
  15. 5/94    dgp wrote it.
  16. 7/29/94 dgp added support for Metrowerks CodeWarrior C compiler.
  17. 7/31/94    dgp changed NaN code from 4 to 21.
  18. */
  19. #define code 21    /* means "attempted to create a NaN with a zero code" */
  20. #if (THINK_C || THINK_CPLUS || SYMANTEC_C)
  21.     #if __option(double_8)
  22.         const short __NAN[]={ 0x7FF0, code<<5, 0, 0 };
  23.     #else
  24.         #if !__option(native_fp)
  25.             const short __NAN[]={ 0x7FFF, 0x7FFF, code, 0, 0, 0 };
  26.         #elif __option(mc68881)
  27.             const short __NAN[]={ 0x7FFF, 0, code, 0, 0, 0 };
  28.         #else
  29.             const short __NAN[]={ 0x7FFF, code, 0, 0, 0 };
  30.         #endif
  31.     #endif
  32. #endif
  33.  
  34. #if __MWERKS__
  35.     #if __ieeedoubles__
  36.         const short __NAN[]={ 0x7FF0, code<<5, 0, 0 };
  37.     #else
  38.         #if __MC68881__
  39.             const short __NAN[]={ 0x7FFF, 0, code, 0, 0, 0 };
  40.         #else
  41.             const short __NAN[]={ 0x7FFF, code, 0, 0, 0 };
  42.         #endif
  43.     #endif
  44. #endif
  45.